﻿using System;
using fastCSharp;

namespace diantou.web.enterprise
{
    /// <summary>
    /// 考试编辑
    /// </summary>
    [fastCSharp.code.cSharp.webView(IsPage = false, IsPool = true)]
    partial class examDescription : examView<examDescription>
    {
        /// <summary>
        /// 是否复制考试
        /// </summary>
        [fastCSharp.emit.webView.clearMember]
        private bool isCopy;
        /// <summary>
        /// 是否修改描述
        /// </summary>
        private bool isReworkDescription
        {
            get { return exam.Id == 0; }
        }
        /// <summary>
        /// 是否修改结束语
        /// </summary>
        private bool isReworkFinishDescription
        {
            get { return exam.Id == 0; }
        }
        /// <summary>
        /// 是否设置参数
        /// </summary>
        private bool isSetFlag = true;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="examId"></param>
        /// <returns></returns>
        private bool loadView(int examId, int copyId)
        {
            if (examId == 0)
            {
                isCopy = true;
                examId = copyId;
            }
            if (examId == 0)
            {
                exam = diantou.examDataAccess.exam.NullExam;
                exam.StartTime = date.GetDate(date.NowSecond.AddDays(1).toInt());
                exam.EndTime = exam.StartTime.AddDays(1);
                return true;
            }
            if (load(examId))
            {
                //Console.WriteLine(exam.Title);
                if (exam.UserId == currentUserId || !isCopy)
                {
                    if (isCopy)
                    {
                        exam = exam.Clone();
                        exam.Id = 0;
                        exam.Status = dataModel.exam.status.None;
                        exam.StartTime = date.GetDate(date.NowSecond.AddDays(1).toInt());
                        exam.EndTime = exam.StartTime.AddDays(1);
                    }
                    return true;
                }
                exam = null;
                AjaxResponse(webConfig.NotFound404);
            }
            return false;
        }
    }
}
